import 'package:flutter/material.dart';

class DialogUtil {
  static showAlertDialog(
    BuildContext context,
    String titleStr,
    String content, {
    Function sure,
    Function cancel,
  }) {
    return showDialog(
        context: context,
        builder: (BuildContext context) {
          return AlertDialog(
            title: Text(titleStr),
            content: Text(content),
            actions: <Widget>[
              cancel != null
                  ? FlatButton(
                      onPressed: () {
                        if (null != cancel) cancel();
                        Navigator.of(context).pop('-1');
                      },
                      child: Text('取消'))
                  : null,
              FlatButton(
                  onPressed: () {
                    if (null != sure) sure();
                    Navigator.of(context).pop('1');
                  },
                  child: Text('确定')),
            ],
          );
        });
  }
}
